コード例 #1
0
ファイル: spellview.cpp プロジェクト: Kleptoid/openmw
    void SpellView::addGroup(const std::string &label, const std::string& label2)
    {
        if (mScrollView->getChildCount() > 0)
        {
            MyGUI::ImageBox* separator = mScrollView->createWidget<MyGUI::ImageBox>("MW_HLine",
                MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 18),
                MyGUI::Align::Left | MyGUI::Align::Top);
            separator->setNeedMouseFocus(false);
            mLines.push_back(LineInfo(separator, (MyGUI::Widget*)NULL, NoSpellIndex));
        }

        MyGUI::TextBox* groupWidget = mScrollView->createWidget<MyGUI::TextBox>("SandBrightText",
            MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24),
            MyGUI::Align::Left | MyGUI::Align::Top);
        groupWidget->setCaptionWithReplacing(label);
        groupWidget->setTextAlign(MyGUI::Align::Left);
        groupWidget->setNeedMouseFocus(false);

        if (label2 != "")
        {
            MyGUI::TextBox* groupWidget2 = mScrollView->createWidget<MyGUI::TextBox>("SandBrightText",
                MyGUI::IntCoord(0, 0, mScrollView->getWidth(), 24),
                MyGUI::Align::Left | MyGUI::Align::Top);
            groupWidget2->setCaptionWithReplacing(label2);
            groupWidget2->setTextAlign(MyGUI::Align::Right);
            groupWidget2->setNeedMouseFocus(false);

            mLines.push_back(LineInfo(groupWidget, groupWidget2, NoSpellIndex));
        }
        else
            mLines.push_back(LineInfo(groupWidget, (MyGUI::Widget*)NULL, NoSpellIndex));
    }
コード例 #2
0
ファイル: EditFiles.cpp プロジェクト: Purplenigma/oovaide
static std::vector<LineInfo> getLinesInfo(GtkTextView* textView, int height)
    {
    std::vector<LineInfo> linesInfo;

    int y1 = 0;
    int y2 = height;
    gtk_text_view_window_to_buffer_coords(textView, GTK_TEXT_WINDOW_LEFT,
            0, y1, NULL, &y1);
    gtk_text_view_window_to_buffer_coords(textView, GTK_TEXT_WINDOW_LEFT,
            0, y2, NULL, &y2);

    GtkTextIter iter;
    gtk_text_view_get_line_at_y(textView, &iter, y1, NULL);
    while(!gtk_text_iter_is_end(&iter))
        {
        int y, height;
        gtk_text_view_get_line_yrange(textView, &iter, &y, &height);
        int line = gtk_text_iter_get_line(&iter);
        linesInfo.push_back(LineInfo(line+1, y));
        if((y + height) >= y2)
            {
            break;
            }
        gtk_text_iter_forward_line(&iter);
        }
    if(linesInfo.size() == 0)
        {
        linesInfo.push_back(LineInfo(1, 1));
        }
    return linesInfo;
    }
コード例 #3
0
ファイル: Diff.cpp プロジェクト: carlosmccosta/File-Compare
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>   <constructors-destructors>   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
/// Default constructor de Diff, que inicializa as estruturas auxiliares
Diff::Diff(string originalFilename, string modifiedFilename, string patchFilename) :
    originalFileName(originalFilename), modifiedFileName(modifiedFilename), patchFileName(patchFilename) {

    //carregamento dos ficheiros
    try {
        loadFile(originalFilename, originalFileData);
        loadFile(modifiedFilename, modifiedFileData);
    } catch (FileDoesntExistException& e) {
        cout << e.what() << "\n" << endl;
        utils::getUserInput();

        originalFileData.clear();
        modifiedFileData.clear();
    }


    //inicialização das estruturas auxiliares
    originalFilePatched = originalFileData;
    originalFilePatchedLinesStatus = vector <LineChangeType>(originalFileData.size(), LINE_EQUAL);

    originalFileLinesStatus = vector <LineInfo>(originalFileData.size(), LineInfo());
    originalFileMovedLinesIndexsInModifiedFile = vector <int>(originalFileData.size(), LINE_NOT_MOVED_INDEX);
    modifiedFileMovedLinesIndexsInOriginalFile = vector <int>(modifiedFileData.size(), LINE_NOT_MOVED_INDEX);
    modifiedFileLinesPresentedOnOriginal = vector <bool>(modifiedFileData.size(), false);


    //análise dos ficheiros
    analyzeFiles();
}
コード例 #4
0
//----------------------------------------------------------------------------//
void RenderedString::appendLineBreak()
{
    const size_t first_component = d_lines.empty() ? 0 :
        d_lines.back().first + d_lines.back().second;

    d_lines.push_back(LineInfo(first_component, 0));
}
コード例 #5
0
ファイル: Exceptions.cpp プロジェクト: epilk/Rattler
static LineInfo GetFileInfo(SourceLocation loc) {
  std::ifstream stream(loc.filename);

  if (!stream.good()) {
    throw InternalCompilerError(StringBuilder(
        "Can't reopen file '", loc.filename, "' after error found in it."));
  }

  // We need to iterate through the file to get the line number information.
  // Can't store this in SourceLocation because it needs to be as small as
  // possible. This is fine, because we would only need to do it once for bad
  // input in a compilation pass, and we are already at *at least* O(n) on the
  // file length
  int lineCount = 0;
  std::array<char, 256> lineArray;

  while (stream.tellg() < loc.offset) {
    lineCount++;
    stream.getline(&lineArray[0], 256);
  }

  std::string line(&lineArray[0]);

  int lineOffset = line.size() - (stream.tellg() - loc.offset);
  return LineInfo(loc.filename, line, lineCount, lineOffset);
}
コード例 #6
0
// Have a special helper function for syntax errors, since we want to include the location
// of the syntax error in the traceback, even though it is not part of the execution:
void raiseSyntaxError(const char* msg, int lineno, int col_offset, llvm::StringRef file, llvm::StringRef func) {
    Box* exc = runtimeCall(SyntaxError, ArgPassSpec(1), boxString(msg), NULL, NULL, NULL, NULL);

    auto tb = new BoxedTraceback(LineInfo(lineno, col_offset, boxString(file), boxString(func)), None);
    assert(!PyErr_Occurred());
    throw ExcInfo(exc->cls, exc, tb);
}
コード例 #7
0
extern "C" void caughtCapiException(AST_stmt* stmt, void* _source_info) {
    SourceInfo* source = static_cast<SourceInfo*>(_source_info);
    PyThreadState* tstate = PyThreadState_GET();

    exceptionAtLine(LineInfo(stmt->lineno, stmt->col_offset, source->getFn(), source->getName()),
                    &tstate->curexc_traceback);
}
コード例 #8
0
ファイル: llconsole.cpp プロジェクト: xinyaojiejie/Dale
void LLConsole::addLine(const LLWString& wline, F32 size, const LLColor4 &color)
{
	while (mLineQueue.size() >= mMaxLines)
	{
		mLineQueue.pop_front();
	}
	mLineQueue.push_back(LineInfo(wline, size, color, mTimer.getElapsedTimeF32()));
}
コード例 #9
0
ファイル: Layout.cpp プロジェクト: misohena/piclist
std::pair<std::size_t, Layout::LineInfo> Layout::findLine(std::size_t index) const
{
	if(lines_.empty()){
		return std::pair<std::size_t, LineInfo>(0, LineInfo(0, 0));
	}

	LineContainer::const_iterator it = lines_.lower_bound(index);
	if(it == lines_.end()){
		return *lines_.rbegin();
	}
	if(it->first == index){
		return *it;
	}
	if(it == lines_.begin()){
		return std::pair<std::size_t, LineInfo>(0, LineInfo(0, 0));
	}
	--it;
	return *it;
}
コード例 #10
0
ファイル: SMFile.cpp プロジェクト: obarnet/Teste
void SMFile::DoSearch(const QStringList& keyword, const Qt::CaseSensitivity& caseSensitive, QRegExp::PatternSyntax syntax)
{
	Entex ee("SMFile::DoSearch", 3);

	if (keyword.isEmpty())
		return;

	QFile file(fileInfo.filePath());
	if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
	{
		qDebug() << "file open failed";  //Todo:: throw exception
		return;
	}
	QTextStream in(&file);
	int lineNo = 1;

	// Todo:: maybe we should have some sort of SearchResult builder to build
	// SearchResult which has the knowledge of SearchSessionId and takes in a
	// QFileInfo as parameter
	Result result(new SearchResult(searchSessionId, fileInfo));

	while (!in.atEnd())
	{
		if (stopIssued == true)
			break;

		QString line = in.readLine();

		if (IsLineMatched(line, keyword[0], caseSensitive, syntax))
		{
			qd(4) << "found matched line";
			result->matchedLines.push_back(LineInfo(lineNo, line));
		}

		++lineNo;
	}
	if (result->matchedLines.empty() == false)
		Notify(result);
}
コード例 #11
0
//! updates a text vertex buffer
void GeometryProvider::UpdateTextVertexBuffer(VertexBuffer* pVertexBuffer, Font* pFont, const std::string& text, const Size& size, Text::E_Alignement alignement, u32 lineSpacing, const Color& color)
{
    s32 maxCharactersPerLine = size.Width/s32(pFont->GetCharacterSize().X);

    std::vector<std::string> words;
    Utils::Tokenize(text.c_str(), " ", words);

    std::vector< LineInfo > lines;
    u32 currentLine = 0;
    s32 charactersRemainingThisLine = maxCharactersPerLine;
    u32 totalCharacters = 0;
    for(u32 currentWord=0; currentWord < words.size(); ++currentWord)
    {
        if(currentLine == lines.size())
        {
            lines.push_back(LineInfo());
        }

        if(s32(words[currentWord].length()) < charactersRemainingThisLine
                || lines[currentLine].words.empty())
        {
            charactersRemainingThisLine -= words[currentWord].length();
            --charactersRemainingThisLine; // consume one space
            if(!lines[currentLine].words.empty())
            {
                lines[currentLine].numCharacters++; // consume one space
                ++totalCharacters;
            }
            u32 wordLength = words[currentWord].length();
            std::string word = words[currentWord].substr(0, Math::Min(wordLength, u32(maxCharactersPerLine)));
            lines[currentLine].words.push_back(word);
            lines[currentLine].numCharacters += word.length();
            totalCharacters += word.length();
        }
        else
        {
            charactersRemainingThisLine = maxCharactersPerLine;
            ++currentLine;
            --currentWord;
        }
    }

    u32 numVertices = totalCharacters*6;
    if(numVertices > pVertexBuffer->GetMaxVertices())
    {
        Vertex3D* pVertices = snew Vertex3D[numVertices];
        pVertexBuffer->SetVertices(pVertices, numVertices);
    }
    pVertexBuffer->SetNumVertices(0);
    pVertexBuffer->SetMaxVertices(numVertices);

    u32 currentCharacter = 0;
    for(u32 i=0; i<lines.size(); ++i)
    {
        Vector2 vCharacterPos(0.0f, f32(i*lineSpacing));

        switch(alignement)
        {
        case Text::A_Center:
            vCharacterPos.X = (f32(size.Width)-(pFont->GetCharacterSize().X*lines[i].numCharacters))/2.0f;
            break;

        case Text::A_Right:
            vCharacterPos.X = f32(size.Width)-(pFont->GetCharacterSize().X*lines[i].numCharacters);
            break;
        }

        for(u32 j=0; j<lines[i].words.size(); ++j)
        {
            for(u32 k=0; k<lines[i].words[j].length(); ++k)
            {
                AddCharacter(pVertexBuffer, pFont, lines[i].words[j].at(k), vCharacterPos, currentCharacter++, color);
                vCharacterPos.X += pFont->GetCharacterSize().X;
            }

            if(j+1 < lines[i].words.size())
            {
                AddCharacter(pVertexBuffer, pFont, ' ', vCharacterPos, currentCharacter++, color);
                vCharacterPos.X += pFont->GetCharacterSize().X;
            }
        }
    }
}
コード例 #12
0
ファイル: checker.cpp プロジェクト: luchiel/Unilint
void Checker::process_file()
{
    srchilite::RegexRuleFactory rule_factory;
    srchilite::LangDefManager lang_def_manager(&rule_factory);
    srchilite::SourceHighlighter highlighter(
        lang_def_manager.getHighlightState(LANG_PATH, file_language.second));
    srchilite::FormatterManager manager(
        PseudoFormatterPtr(new PseudoFormatter(token_types, tokens, env.current_line_index)));

    manager.addFormatter("cbracket_open", new_formatter("cbracket_open"));
    manager.addFormatter("cbracket_close", new_formatter("cbracket_close"));
    manager.addFormatter("pasbracket_open", new_formatter("pasbracket_open"));
    manager.addFormatter("pasbracket_close", new_formatter("pasbracket_close"));

    manager.addFormatter("keyword", new_formatter("keyword"));
    manager.addFormatter("number", new_formatter("number"));
    manager.addFormatter("label", new_formatter("label"));
    manager.addFormatter("preproc", new_formatter("preproc"));
    manager.addFormatter("comment", new_formatter("comment"));
    manager.addFormatter("string", new_formatter("string"));
    manager.addFormatter("specialchar", new_formatter("string"));
    manager.addFormatter("symbol", new_formatter("symbol"));

    manager.addFormatter("type", new_formatter("type"));
    manager.addFormatter("usertype", new_formatter("classname"));
    manager.addFormatter("classname", new_formatter("classname"));
    manager.addFormatter("function", new_formatter("function"));
    manager.addFormatter("identifier", new_formatter("identifier"));

    manager.addFormatter("case", new_formatter("case"));
    manager.addFormatter("of", new_formatter("of"));
    manager.addFormatter("typeblock", new_formatter("typeblock"));
    manager.addFormatter("varblock", new_formatter("varblock"));
    manager.addFormatter("keyword_declaring_varblock", new_formatter("keyword_declaring_varblock"));
    manager.addFormatter("keyword_declaring_func", new_formatter("keyword_declaring_func"));

    manager.addFormatter(
        "keyword_with_following_operation", new_formatter("keyword_with_following_operation"));
    manager.addFormatter(
        "keyword_with_following_operation_after_braces",
        new_formatter("keyword_with_following_operation_after_braces"));
    manager.addFormatter("switch_labels", new_formatter("switch_labels"));
    manager.addFormatter("semicolon", new_formatter("semicolon"));
    manager.addFormatter("brace", new_formatter("brace"));
    manager.addFormatter("bracket", new_formatter("bracket"));

    highlighter.setFormatterManager(&manager);

    srchilite::FormatterParams params;
    highlighter.setFormatterParams(&params);

    for(env.current_line_index = 0; file_to_process.good(); ++env.current_line_index)
    {
        getline(file_to_process, env.current_line);
        check_line_length();
        check_if_empty();
        lines.push_back(LineInfo(env.current_line, env.current_line.size(), 0, 0, 0));
        if(env.current_line.size() != 0)
        {
            params.start = 0;
            highlighter.highlightParagraph(env.current_line);
        };
    }
    check_newline_at_eof();
    calculate_expected_depth();
    if(settings.indentation_policy != IP_IGNORE)
        check_indentation();
    process_tokens();
}
コード例 #13
0
ファイル: Font.cpp プロジェクト: dreamsxin/rainbrurpg
/** Feed the LineInfoList for the given text
  *
  * \param vText  The text to draw
  * \param vWidth The allowed width
  * \param vOut   The LineInfoList to feed
  * \param vWrap  The word wrap parameter
  *
  */
void RainbruRPG::OgreGui::Font::
processText( const std::string& vText, float vWidth, 
	     LineInfoList& vOut, bool vWrap)const{

  // Get the total size of the text
  unsigned int count = (unsigned int)vText.size( );

  // Stores pixel width of line and word
  float lineWidth = 0.0f;
  float wordWidth = 0.0f;

  // Stores current word
  std::string word;

  // Stores the current line
  std::string line;

  unsigned int x;
  for ( x = 0; x < count; x++ ){
    char c = vText[x];

    // Add the new character to the current word
    Glyph* gl=getGlyph(c);
    wordWidth += gl->getSpace();
    word += c;

    bool delim=isDelim(c);
    if ( delim || ( x == ( count-1 ) ) ){
      // Is this line too long to fit?
      if ( vWrap && ( lineWidth + wordWidth > vWidth ) ){
	// Save current line
	vOut.push_back( LineInfo( line, lineWidth ) );

	// Reset line width
	lineWidth = 0.0f;
	line = "";
      }
      if ( c == '\n' ){
	// Save current line
	vOut.push_back( LineInfo( line + word, lineWidth + wordWidth ) );

	// Reset line width
	lineWidth = 0.0f;
	wordWidth = 0.0f;

	line = "";
	word = "";
      }
      else{
	lineWidth += wordWidth;
	line += word;

	wordWidth = 0.0f;
	word = "";
      }
    }
  }
  
  // Push any remaining text onto list
  vOut.push_back( LineInfo( line + word, lineWidth + wordWidth ) );
}
コード例 #14
0
ファイル: spellview.cpp プロジェクト: Kleptoid/openmw
    void SpellView::update()
    {
        if (!mModel.get())
            return;

        mModel->update();

        int curType = -1;

        const int spellHeight = 18;

        mLines.clear();

        while (mScrollView->getChildCount())
            MyGUI::Gui::getInstance().destroyWidget(mScrollView->getChildAt(0));

        for (SpellModel::ModelIndex i = 0; i<int(mModel->getItemCount()); ++i)
        {
            const Spell& spell = mModel->getItem(i);
            if (curType != spell.mType)
            {
                if (spell.mType == Spell::Type_Power)
                    addGroup("#{sPowers}", "");
                else if (spell.mType == Spell::Type_Spell)
                    addGroup("#{sSpells}", "#{sCostChance}");
                else
                    addGroup("#{sMagicItem}", "#{sCostCharge}");
                curType = spell.mType;
            }

            const std::string skin = spell.mActive ? "SandTextButton" : "SpellTextUnequipped";

            Gui::SharedStateButton* t = mScrollView->createWidget<Gui::SharedStateButton>(skin,
                MyGUI::IntCoord(0, 0, 0, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
            t->setCaption(spell.mName);
            t->setTextAlign(MyGUI::Align::Left);
            adjustSpellWidget(spell, i, t);

            if (!spell.mCostColumn.empty() && mShowCostColumn)
            {
                Gui::SharedStateButton* costChance = mScrollView->createWidget<Gui::SharedStateButton>(skin,
                    MyGUI::IntCoord(0, 0, 0, spellHeight), MyGUI::Align::Left | MyGUI::Align::Top);
                costChance->setCaption(spell.mCostColumn);
                costChance->setTextAlign(MyGUI::Align::Right);
                adjustSpellWidget(spell, i, costChance);

                Gui::ButtonGroup group;
                group.push_back(t);
                group.push_back(costChance);
                Gui::SharedStateButton::createButtonGroup(group);

                mLines.push_back(LineInfo(t, costChance, i));
            }
            else
                mLines.push_back(LineInfo(t, (MyGUI::Widget*)NULL, i));

            t->setStateSelected(spell.mSelected);
        }

        layoutWidgets();
    }
コード例 #15
0
ファイル: Layout.cpp プロジェクト: misohena/piclist
void Layout::update(const AlbumItemContainer &items, const Size2i &clientSize, ImageCache &imageCache)
{
	updateCellLayout();

	lines_.clear();
	itemCount_ = items.size();
	columns_ = std::max(1, (clientSize.w + columnSpace_) / cellStepX_);

	typedef AlbumItemContainer::const_iterator ItemIt;

	class LineDivider
	{
		const unsigned int columns_;
		const ItemIt beg_;
		const ItemIt end_;
		ItemIt curr_;
	public:
		LineDivider(unsigned int columns, const ItemIt &beg, const ItemIt &end)
			: columns_(columns), beg_(beg), end_(end), curr_(beg) {}

		bool isTerminated() const { return curr_ == end_;}
		const ItemIt &getCurrent() const { return curr_;}
		ItemIt getLineEnd()
		{
			unsigned int count = 0;
			for(;;){
				if(curr_ == end_){
					return curr_;
				}
				if((*curr_)->isLineBreak()){
					const ItemIt lineEnd = curr_;
					++curr_;
					return lineEnd;
				}
				if(count++ >= columns_){
					return curr_;
				}
				++curr_;
			}
		}
	};

	LineDivider lineDivider(columns_, items.begin(), items.end());

	int lineTop = 0;
	while(!lineDivider.isTerminated()){
		const ItemIt lineBeg = lineDivider.getCurrent();
		const ItemIt lineEnd = lineDivider.getLineEnd();

		// 画像の高さがAUTOの場合、行内の最大の画像の高さを求める。
		if(isImageHeightAuto()){
			const int maxImageHeight = std::accumulate(lineBeg, lineEnd, 0, [&](int maxImageHeight, const AlbumItemPtr &item) -> int {
				switch(item->getType()){
				case AlbumItem::TYPE_LINE_BREAK:
					break;
				case AlbumItem::TYPE_PICTURE:
					if(const AlbumPicture *pic = dynamic_cast<const AlbumPicture *>(item.get())){
						if(const ImagePtr im = imageCache.getImage(pic->getFilePath(), Size2i(getImageWidth(), getImageHeight()))){
							return std::max(maxImageHeight, im->getHeight());
						}
					}
					break;
				}
				return maxImageHeight;
			});
			lines_.insert(LineContainer::value_type(lineBeg - items.begin(), LineInfo(lineTop, maxImageHeight)));
			lineTop += maxImageHeight + nameHeight_ + lineSpace_;
		}
		else{
			lines_.insert(LineContainer::value_type(lineBeg - items.begin(), LineInfo(lineTop, imageHeight_)));
			lineTop += cellStepY_;
		}

	}

	pageSize_.set(
		columns_ * cellStepX_ - columnSpace_,
		lineTop ? lineTop - lineSpace_ : 0);
}
コード例 #16
0
HRESULT CTextTraceFile::ParseBlock(LoadBlock * pBlock, DWORD nStart, DWORD nStop, DWORD * pnStop, DWORD * pnLineEnd)
{
	HRESULT hr = S_OK;
	char * pszCur;
	char * pszEnd;
	char * pszLine = NULL;
	WORD crcn = 0;

	BOOL fSkipSpace = FALSE;
	DWORD nVal = 0;

	LockGuard guard(m_Lock);

	// test unicode file
	pszCur = (char*) (pBlock->pbBuf + nStart);
	pszEnd = (char*) (pBlock->pbBuf + nStop);

	if (pBlock->nFileStart == 0 && pBlock->cbData > 2)
	{
		if (pBlock->pbBuf[0] == 0xff && pBlock->pbBuf[1] == 0xfe)
		{
			LOG("@%p unicode mode");
			m_bUnicode = true;
			pszCur += 2;
		}
	}


	if (m_bUnicode)
	{
		wchar_t c;
		wchar_t* pszCurW = reinterpret_cast<wchar_t*>(pszCur);
		wchar_t* pszEndW = reinterpret_cast<wchar_t*>(pszEnd);
		wchar_t* pszLineW = reinterpret_cast<wchar_t*>(pszCur);

		for (; pszCurW < pszEndW; pszCurW++)
		{
			c = *pszCurW;

			crcn <<= 8;
			crcn |= (char) c;

			if (crcn == 0x0d0a)
			{
				// for now just drop first bytes
				char* pszLine = pszCur;
				for (wchar_t* p = pszLineW; p <= pszCurW; p++, pszCur++)
				{
					*pszCur = (char) *p;
				}

				// pszCur points after pszCurW so we do not need +1
				m_Lines.Add(LineInfo(CStringRef(pszLine, pszCur - pszLine), m_Lines.GetSize()));
				pszLineW = pszCurW + 1;
			}
		}

		(*pnStop) = ((BYTE*) pszCur - pBlock->pbBuf);
		(*pnLineEnd) = (pszLineW) ? ((BYTE*) pszLineW - pBlock->pbBuf) : ((BYTE*) pszEndW - pBlock->pbBuf);
	}
	else
	{
		pszLine = pszCur;
		char c;
		for (; pszCur < pszEnd; pszCur++)
		{
			c = *pszCur;

			crcn <<= 8;
			crcn |= c;

			if (crcn == 0x0d0a)
			{
				m_Lines.Add(LineInfo(CStringRef(pszLine, pszCur - pszLine + 1), m_Lines.GetSize()));
				pszLine = pszCur + 1;
			}
		}

		(*pnStop) = nStop;
		(*pnLineEnd) = (pszLine) ? ((BYTE*) pszLine - pBlock->pbBuf) : ((BYTE*) pszEnd - pBlock->pbBuf);
	}

	// we are parsing under lock; it is safe to adjust the size
	m_LineParsed.Resize(m_Lines.GetSize());

	//Cleanup:

	return hr;
}
コード例 #17
0
ファイル: TER_FRM2.C プロジェクト: killbug2004/WSProf
/******************************************************************************
    CreateCellFrame:
    Create a Cell frame.
*******************************************************************************/
CreateCellFrame(PTERWND w,int level,LPINT pFrameNo,int y,int ScrY, LPINT pFrameHt,LPINT pScrFrameHt, 
                 int CurColHeight,int ScrCurColHeight, LPINT pFirstCellFrame, 
                 LPINT pTableRowHeight, LPINT pScrTableRowHeight,LPINT pCellX,int TableRowIndent,
                 int PageNo,int TopLeftMargin,int ColumnNo,int sect,int PrevCell, LPINT pCellFramed,
                 long FrameFirstLine, long FrameLastLine, UINT PassFlags, BOOL RowBreak,
                 LPINT pCellWidth, int TextWidth,int MaxColumns, int ColumnSpace, int PageWdth,
                 int ColumnX,int ColumnWidth, int BoxFrame, int ParaFrameId)
{
    int TblCellHeight,LeftWidth,RightWidth,TopWidth,BotWidth,SpaceTop,SpaceBot;
    int row,CellLeftMarg,CellRightMarg,CellMargin,FrameSpaceHt;
    BOOL IsFirstCellFrame=FALSE;
    UINT border;
    int ParentLeftMargin,ParentRightMargin;
    int  pad,i,x,PrevRowId=cell[PrevCell].row;
    COLORREF BorderColor[4];
    long l;

    //dm("CreateCellFrame");

    // define the argument for easy reference
    #define FrameNo (*pFrameNo)
    #define FrameHt (*pFrameHt)
    #define ScrFrameHt (*pScrFrameHt)
    #define FirstCellFrame (*pFirstCellFrame)
    #define TableRowHeight (*pTableRowHeight)
    #define ScrTableRowHeight (*pScrTableRowHeight)
    #define CellX (*pCellX)
    #define CellFramed (*pCellFramed)
    #define CellWidth (*pCellWidth)

    
    // calcualte parent cell margin
    if (level>0) {
       int ParentCell=cell[PrevCell].ParentCell;
       ParentLeftMargin=TwipsToPrtX(CellLeftMargin(w,ParentCell));
       ParentRightMargin=TwipsToPrtX(CellRightMargin(w,ParentCell));
    }
    else ParentLeftMargin=ParentRightMargin=0;

    // adjust y from any frame space before the row
    row=cell[PrevCell].row;
    FrameSpaceHt=TableRow[row].FrmSpcBef;
    if (FrameSpaceHt>0) {
       y+=FrameSpaceHt;
       ScrY+=PrtToScrY(FrameSpaceHt);
    } 

    // update table row height
    if (FirstCellFrame==-1) {
        int MinHeight;
        FirstCellFrame=FrameNo; // first frame for the row
        MinHeight=TableRow[PrevRowId].MinHeight;
        if (True(TableRow[PrevRowId].flags&ROWFLAG_SPLIT) /*&& TableAux[PrevRowId].FirstPage==PageNo */ && MinHeight>0) MinHeight=0;  // 20051201 - min-height not supported at page-bot/top to keep the row height within the page-body area
        if (MinHeight<0) MinHeight=-MinHeight;   // exact match

        if (TableRow[PrevRowId].MinPictHeight>MinHeight) MinHeight=TableRow[PrevRowId].MinPictHeight;  // height of the picture frames
        TableRowHeight=TwipsToPrtY(MinHeight);
        ScrTableRowHeight=TwipsToScrY(MinHeight);
        IsFirstCellFrame=TRUE;

    }

    // set the border and space top/bottom
    border=GetCellFrameBorder(w,PrevCell,&LeftWidth,&RightWidth,&TopWidth,&BotWidth,PageNo,BorderColor);
    if (CellAux[PrevCell].flags&CAUX_SET_TOP_SPACE) SpaceTop=TwipsToPrtY(cell[PrevCell].margin);  // use extra space
    else  {
       pad=CellTopPad(w,PrevCell);
       SpaceTop=TwipsToPrtY(TopWidth+pad);    // 20070430
    }
    pad=CellBotPad(w,PrevCell);
    SpaceBot=TwipsToPrtY(BotWidth+pad); 

    // adjust the frame height
    FrameHt+=(SpaceTop+SpaceBot);
    ScrFrameHt+=PrtToScrY(SpaceTop+SpaceBot);
    
    // keep track of max row height
    TblCellHeight=0;        // height contribute by this cell toward the row
    if (IsLastSpannedCell(w,PrevCell)) TblCellHeight=GetLastSpannedCellHeight(w,PrevCell,NULL,PageNo);  // height contrinution of this cell toward the row height
    else if ((cell[PrevCell].RowSpan==1 || IsPageLastRow(w,cell[PrevCell].row,PageNo)) 
             && !(cell[PrevCell].flags&CFLAG_ROW_SPANNED)) {
         TblCellHeight=FrameHt;
         if (cell[PrevCell].TextAngle!=0) TblCellHeight=TwipsToPrtY(MIN_VTEXT_CELL_HEIGHT);  // vertical text does not affect the row height
         
         if (cell[PrevCell].flags&CFLAG_VALIGN_BASE) TblCellHeight+=CellAux[PrevCell].SpaceBefore;  // add base alignment adjustment
    }
    if (TableRow[PrevRowId].MinHeight>=0) {
        if (TblCellHeight>TableRowHeight) TableRowHeight=TblCellHeight;
    }
    ScrTableRowHeight=PrtToScrY(TableRowHeight);

    if (RowBreak) {            // last cell of the table
        int row=cell[PrevCell].row;

        // 20070104: check for a hidden row
        for (i=FirstCellFrame;i<=FrameNo;i++) {
           int LastLine=frame[i].PageLastLine;
           int FirstLine=frame[i].PageFirstLine;
           if (frame[i].empty) continue;
           
           if (i==FrameNo) {           // the frame for the last cell not yet built
              FirstLine=FrameFirstLine;
              LastLine=FrameLastLine;
           } 
           for (l=FirstLine;l<=LastLine;l++) {
             int height=LineHt(l);
             if (height>0 && LineLen(l)==1 && LineInfo(w,l,INFO_CELL) && IsHiddenLine(w,l)) height=0;
             if (height!=0) break;
           }
           if (l<=LastLine) break;
        } 
        if (i>FrameNo) ScrTableRowHeight=TableRowHeight=0;   // all text in the row hidden - hide the row

        TableRow[row].height=TableRowHeight;  // record the updated table row height

        for (i=FirstCellFrame;i<=FrameNo;i++) {
            if (frame[i].level!=level) continue;
            
            frame[i].height=TableRowHeight;
            frame[i].ScrHeight=ScrTableRowHeight;
        }
        FirstCellFrame=-1;      // reset for the next row

    }

    // create the empty row indentation frame
    if (IsFirstCellFrame) {
        int row=cell[PrevCell].row;

        // create the empty frame to reserve any frame space
        if (TableRow[row].FrmSpcBef>0) {
            int SpcBef=TableRow[row].FrmSpcBef;
            frame[FrameNo].empty=TRUE;
            frame[FrameNo].PageNo=PageNo;             // 20070511
            frame[FrameNo].level=level;
            frame[FrameNo].sect=sect;     // section to which the frame belongs
            frame[FrameNo].x=CellX;
            frame[FrameNo].y=y+CurColHeight-SpcBef;  // relative to top margin
            frame[FrameNo].ScrY=ScrY+ScrCurColHeight-PrtToScrY(SpcBef);  // relative to top margin
            frame[FrameNo].width=TextWidth;
            frame[FrameNo].BoxFrame=BoxFrame;
            frame[FrameNo].ParaFrameId=ParaFrameId;
            if (ParaFrameId>0) frame[FrameNo].ZOrder=ParaFrame[ParaFrameId].ZOrder;
            if (!BorderShowing && level==0) frame[FrameNo].flags|=FRAME_RIGHTMOST;

            frame[FrameNo].height=SpcBef;
            frame[FrameNo].ScrHeight=PrtToScrY(SpcBef);

            FrameNo++;                      // advance to the next frame
            if (!InitFrame(w,FrameNo)) AbortTer(w,"Ran Out of Text Frame Table (CreateFrames 1)",1);

            if (FirstCellFrame>=0) FirstCellFrame=FrameNo; // first frame for the row
        }

        TableRow[PrevRowId].FirstFrame=FrameNo;  // first frame of the row

        frame[FrameNo].empty=TRUE;
        frame[FrameNo].PageNo=PageNo;             // 20070511
        frame[FrameNo].level=level;
        frame[FrameNo].sect=sect;     // section to which the frame belongs
        frame[FrameNo].y=y+CurColHeight;  // relative to top margin
        frame[FrameNo].ScrY=ScrY+ScrCurColHeight;  // relative to top margin
        frame[FrameNo].BoxFrame=BoxFrame;
        frame[FrameNo].ParaFrameId=ParaFrameId;
        if (ParaFrameId>0) frame[FrameNo].ZOrder=ParaFrame[ParaFrameId].ZOrder;
        frame[FrameNo].CellId=PrevCell;

        frame[FrameNo].width=TableRow[PrevRowId].CurIndent;   // TableRowIndent;
        frame[FrameNo].x=CellX;

        frame[FrameNo].border=0;
        frame[FrameNo].RowId=PrevRowId;
        frame[FrameNo].height=FrameHt=TableRowHeight;
        frame[FrameNo].ScrHeight=ScrFrameHt=ScrTableRowHeight;
        frame[FrameNo].flags|=FRAME_FIRST_ROW_FRAME;

        CellX=CellX+frame[FrameNo].width;

        FrameNo++;                      // advance to the next frame
        if (!InitFrame(w,FrameNo)) AbortTer(w,"Ran Out of Text Frame Table (CreateFrames 1)",1);
    }

    // create any intervening empty cell frames
    FrameEmptyCells(w,PrevRowId,&CellFramed,PrevCell,&CellX,y+CurColHeight,TableRowHeight,&FrameNo,sect,PageNo);

    // create the text frame
    CellMargin=TwipsToPrtX(cell[PrevCell].margin);
    CellLeftMarg=TwipsToPrtX(CellLeftMargin(w,PrevCell));
    CellRightMarg=TwipsToPrtX(CellRightMargin(w,PrevCell));
    CellWidth=TwipsToPrtX(cell[PrevCell].width);

    frame[FrameNo].empty=FALSE;
    frame[FrameNo].PageNo=PageNo;             // 20070511
    frame[FrameNo].level=level;
    frame[FrameNo].sect=sect;     // section to which the frame belongs
    frame[FrameNo].PageFirstLine=FrameFirstLine;
    frame[FrameNo].PageLastLine=FrameLastLine;
    frame[FrameNo].y=y+CurColHeight;  // relative to top margin
    frame[FrameNo].ScrY=ScrY+ScrCurColHeight;  // relative to top margin
    frame[FrameNo].BoxFrame=BoxFrame;
    frame[FrameNo].ParaFrameId=ParaFrameId;
    if (ParaFrameId>0) frame[FrameNo].ZOrder=ParaFrame[ParaFrameId].ZOrder;
    frame[FrameNo].shading=cell[PrevCell].shading; // shading percentage
    
    frame[FrameNo].BackColor=cell[PrevCell].BackColor; // background color
    if (cell[PrevCell].BackColor==CLR_WHITE && cell[PrevCell].ParentCell>0 && False(cell[PrevCell].flags&CFLAG_FORCE_BKND_CLR)) { // check if parent cell is non-white
       int ParentCell=cell[PrevCell].ParentCell;
       while (ParentCell>0) {
          if (cell[ParentCell].BackColor!=CLR_WHITE || True(cell[ParentCell].flags&CFLAG_FORCE_BKND_CLR)) break;
          ParentCell=cell[ParentCell].ParentCell;
       }
       if (ParentCell>0) {
         frame[FrameNo].BackColor=cell[PrevCell].BackColor; // 20060313 
         frame[FrameNo].flags|=FRAME_FORCE_BKND_CLR;        // to foce drawing of white color if any
       }
    } 

    frame[FrameNo].flags|=PassFlags;  // flags for the pass
    if (cell[PrevCell].flags&CFLAG_FORCE_BKND_CLR) frame[FrameNo].flags|=FRAME_FORCE_BKND_CLR;  // enforce background color even for default color

    frame[FrameNo].x=CellX;
    frame[FrameNo].width=CellWidth;
    frame[FrameNo].SpaceLeft=CellLeftMarg;
    if (HtmlMode && IsFirstCellFrame && border&BORDER_LEFT) frame[FrameNo].SpaceLeft+=ScrToPrtX(3);  // add width of the html table border
    frame[FrameNo].SpaceRight=CellRightMarg;

    // record the frame x space for the row
    if (IsFirstCellFrame) TableAux[PrevRowId].FrmBegX=frame[FrameNo].x;
    TableAux[PrevRowId].FrmEndX=frame[FrameNo].x+frame[FrameNo].width;;

    frame[FrameNo].border=border;
    frame[FrameNo].BorderWidth[BORDER_INDEX_LEFT]=LeftWidth;
    frame[FrameNo].BorderWidth[BORDER_INDEX_RIGHT]=RightWidth;
    frame[FrameNo].BorderWidth[BORDER_INDEX_TOP]=TopWidth;
    frame[FrameNo].BorderWidth[BORDER_INDEX_BOT]=BotWidth;

    // set border color
    for (i=0;i<4;i++) frame[FrameNo].BorderColor[i]=BorderColor[i];
    
    frame[FrameNo].RowId=PrevRowId;

    if (cell[PrevCell].flags&CFLAG_ROW_SPANNED)    // set height
        frame[FrameNo].TextHeight=frame[FrameNo].height=frame[FrameNo].ScrHeight=0;
    else {
        frame[FrameNo].TextHeight=ScrFrameHt-PrtToScrY(SpaceBot);
        frame[FrameNo].height=TableRowHeight;
        frame[FrameNo].ScrHeight=ScrTableRowHeight;
    }
    FrameHt=TableRowHeight;
    ScrFrameHt=ScrTableRowHeight;

    frame[FrameNo].SpaceTop=SpaceTop;
    frame[FrameNo].SpaceBot=SpaceBot;
    frame[FrameNo].CellId=PrevCell;


    CellFramed=PrevCell;
        
    FrameNo++;                      // advance to the next frame
    if (!InitFrame(w,FrameNo)) AbortTer(w,"Ran Out of Text Frame Table (CreateFrames 4)",1);

    // on row break create an empty frame on the right to cover any blank area
    x=frame[FrameNo-1].x+frame[FrameNo-1].width;  // right edge of the right most frame
    if (RowBreak) {
        if (true || level==0) FrameEmptyCells(w,PrevRowId,&CellFramed,0,&x,frame[FrameNo-1].y,frame[FrameNo-1].height,&FrameNo,sect,PageNo);

        TableRow[PrevRowId].LastFrame=FrameNo;

        frame[FrameNo].empty=TRUE;
        frame[FrameNo].PageNo=PageNo;             // 20070511
        frame[FrameNo].level=level;
        frame[FrameNo].y=frame[FrameNo-1].y;
        frame[FrameNo].ScrY=frame[FrameNo-1].ScrY;
        frame[FrameNo].x=x;
        frame[FrameNo].BoxFrame=BoxFrame;
        frame[FrameNo].ParaFrameId=ParaFrameId;
        if (ParaFrameId>0) frame[FrameNo].ZOrder=ParaFrame[ParaFrameId].ZOrder;

        frame[FrameNo].width=ColumnX+ColumnWidth+ColumnSpace-x;
        if (level==0) {
            if (ParaFrameId>0) { 
               int right=frame[BoxFrame].x+frame[BoxFrame].width-frame[BoxFrame].BorderWidth[BORDER_INDEX_RIGHT];
               frame[FrameNo].width=right-frame[FrameNo].x;
            } 
            else if (BorderShowing) {
               if (MaxColumns==1 || ((ColumnNo+1)==MaxColumns)) {
                  int sect=frame[FrameNo-1].sect;
                  frame[FrameNo].width=PageWdth-LeftBorderWidth-(int)(TerSect[sect].RightMargin*PrtResX)-x;
               }
               else  frame[FrameNo].flags|=FRAME_LINE_BET_COL;  // line between columns
            }
            else {
               frame[FrameNo].flags|=FRAME_RIGHTMOST;
               if ((ColumnNo+1)<MaxColumns) frame[FrameNo].flags|=FRAME_LINE_BET_COL;  // line between columns
            }
        }

        if (frame[FrameNo].width<0) frame[FrameNo].width=0;

        frame[FrameNo].height=frame[FrameNo-1].height;
        frame[FrameNo].ScrHeight=frame[FrameNo-1].ScrHeight;
        frame[FrameNo].sect=frame[FrameNo-1].sect;
        frame[FrameNo].RowId=frame[FrameNo-1].RowId;
        frame[FrameNo].CellId=frame[FrameNo-1].CellId;  // set cell id so that frame height is adjusted properly when this frame is after a spanning cell frame
        frame[FrameNo].flags|=(PassFlags|FRAME_LAST_ROW_FRAME);     // last frame for the row

        CellFramed=0;                   // initialize for the next row
        
        FrameNo++;                      // advance to the next frame
        if (!InitFrame(w,FrameNo)) AbortTer(w,"Ran Out of Text Frame Table (CreateFrames 4)",1);
    }

    // adjust FrameHt to FrameSpace before
    FrameHt+=FrameSpaceHt;
    ScrFrameHt+=PrtToScrY(FrameSpaceHt);

    // undefine the arguments;
    #undef FrameNo
    #undef FrameHt
    #undef ScrFrameHt
    #undef FirstCellFrame
    #undef TableRowHeight
    #undef ScrTableRowHeight
    #undef CellX
    #undef CellFramed
    #undef CellWidth

    return TRUE;
}