Пример #1
0
ChEXPORT WrdDocumentProperties* WrdDocumentProperties::clone() const
{
    ChAutoPtr<WrdDOPTypography> pTypography((WrdDOPTypography*)m_pTypography->clone());
    ChAutoPtr<WrdDrawingObjectGrid> pGrid((WrdDrawingObjectGrid*)m_pGrid->clone());
    ChAutoPtr<WrdAutoSummaryInfo> pInfo((WrdAutoSummaryInfo*)m_pAutoSummary->clone());
    ChAutoPtr<WrdDateTime> pDate1((WrdDateTime*)m_pDateCreated->clone());
    ChAutoPtr<WrdDateTime> pDate2((WrdDateTime*)m_pDateRevised->clone());
    ChAutoPtr<WrdDateTime> pDate3((WrdDateTime*)m_pDateLastPrinted->clone());
    
    WrdDocumentProperties* pProps = ChNEW WrdDocumentProperties
    	((WrdDOPTypography*)pTypography.get(), (WrdDrawingObjectGrid*)pGrid.get(), 
        (WrdAutoSummaryInfo*)pInfo.get(), (WrdDateTime*)pDate1.get(), (WrdDateTime*)pDate2.get(), 
        (WrdDateTime*)pDate3.get());
    
    pDate3.giveUpOwnership();
    pDate2.giveUpOwnership();
    pDate1.giveUpOwnership();
    pInfo.giveUpOwnership();
    pGrid.giveUpOwnership();
    pTypography.giveUpOwnership();
	
	// Need to place this in an auto-pointer in case operator()= throws an exception
	ChAutoPtr<WrdDocumentProperties> pClone(pProps);
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Пример #2
0
    intrusive_ptr<Document> DocumentSourceUnwind::clonePath() const {
        /*
          For this to be valid, we must already have pNoUnwindDocument set,
          and have set up the vector of indices for that document in fieldIndex.
         */
        assert(pNoUnwindDocument.get());

        intrusive_ptr<Document> pClone(pNoUnwindDocument->clone());
        intrusive_ptr<Document> pCurrent(pClone);
        const size_t n = fieldIndex.size();
        assert(n);
        for(size_t i = 0; i < n; ++i) {
            const size_t fi = fieldIndex[i];
            Document::FieldPair fp(pCurrent->getField(fi));
            if (i + 1 < n) {
                /*
                  For every object in the path but the last, clone it and
                  continue on down.
                */
                intrusive_ptr<Document> pNext(
                    fp.second->getDocument()->clone());
                pCurrent->setField(fi, fp.first, Value::createDocument(pNext));
                pCurrent = pNext;
            }
            else {
                /* for the last, subsitute the next unwound value */
                pCurrent->setField(fi, fp.first, pUnwindValue);
            }
        }

        return pClone;
    }
Пример #3
0
CursorEventPtr TouchEvent::cloneAs(Type eventType) const
{
    TouchEventPtr pClone(new TouchEvent(*this));
    if (eventType != UNKNOWN) {
        pClone->m_Type = eventType;
    }
    return pClone;
}
Пример #4
0
ChEXPORT WrdUserRestriction* WrdUserRestriction::clone() const
{	
	WrdUserRestriction* pUserRestriction = ChNEW WrdUserRestriction();
	
	// Need to place this in an auto-pointer in case operator()= throws an exception
	ChAutoPtr<WrdUserRestriction> pClone(pUserRestriction);
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Пример #5
0
ChEXPORT WrdStyleSheet* WrdStyleSheet::clone() const
{
	ChAutoPtr<WrdStyle> pStyle((WrdStyle*)m_pDefaultStyle->clone());
	
	// Can't put this in an auto-pointer due to the order of the cleanup stack
	WrdStyleSheet* pStyleSheet = ChNEW WrdStyleSheet((WrdStyle*)pStyle.get());
	
	pStyle.giveUpOwnership();
	
	// Need to place this in an auto-pointer in case operator()= throws an exception
	ChAutoPtr<WrdStyleSheet> pClone(pStyleSheet);
	*pClone = *this;
	return pClone.giveUpOwnership();
}
ChEXPORT WrdListLevelFormatOverride* WrdListLevelFormatOverride::clone() const
{
	ChAutoPtr<WrdListLevelFormat> pListLevelFormat((WrdListLevelFormat*)m_pListLevelFormat->clone());
	
	// Can't put this in an auto-pointer due to the order of the cleanup stack
	WrdListLevelFormatOverride* pOverride = ChNEW WrdListLevelFormatOverride
		((WrdListLevelFormat*)pListLevelFormat.get());
	
	pListLevelFormat.giveUpOwnership();
	
	// Need to place this in an auto-pointer in case operator()= throws an exception
	ChAutoPtr<WrdListLevelFormatOverride> pClone(pOverride);
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Пример #7
0
ChEXPORT WrdAnnotation* WrdAnnotation::clone() const
{
	ChAutoPtr<WrdAnnotationReferenceDescriptor> pDescriptor((WrdAnnotationReferenceDescriptor*)m_pDescriptor->clone());
    ChAutoPtr<WrdDateTime> pDateTime((WrdDateTime*)m_pDateTime->clone());
	
	// Can't put this in an auto-pointer due to the order of the cleanup stack
	WrdAnnotation* pAnnotation = ChNEW WrdAnnotation((WrdAnnotationReferenceDescriptor*)pDescriptor.get(),
        (WrdDateTime*)pDateTime.get());

    pDateTime.giveUpOwnership();
	pDescriptor.giveUpOwnership();
	
	// Need to place this in an auto-pointer in case operator()= throws an exception
	ChAutoPtr<WrdAnnotation> pClone(pAnnotation);
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Пример #8
0
ChEXPORT WrdCharacterTextRun* WrdCharacterTextRun::clone() const
{
	ChAutoPtr<WrdCharacterProperties> pOrigCharProps((WrdCharacterProperties*)m_pOrigCharProps->clone());
	ChAutoPtr<WrdCharacterProperties> pTrackedCharProps
		((WrdCharacterProperties*)m_pTrackedChangesCharProps->clone());
	
	// Can't put this in an auto-pointer immediately, due to the cleanup stack order.
	WrdCharacterTextRun* pTextRun =
		ChNEW WrdCharacterTextRun(m_textType, m_ulStartCP, 
		(WrdCharacterProperties*)pOrigCharProps.get(), 
		(WrdCharacterProperties*)pTrackedCharProps.get());
	
	pTrackedCharProps.giveUpOwnership();
	pOrigCharProps.giveUpOwnership();
	
	// Need to wrap in an auto-pointer as operator()= could throw an exception
	ChAutoPtr<WrdCharacterTextRun> pClone(pTextRun);
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Пример #9
0
ChEXPORT WrdRoutingSlip* WrdRoutingSlip::clone() const
{
    ChAutoPtr<WrdRoutingSlip> pClone(ChNEW WrdRoutingSlip());
    *pClone = *this;
    return pClone.giveUpOwnership();
}
ChEXPORT WrdEmbeddedTrueTypeFontTable* WrdEmbeddedTrueTypeFontTable::clone() const
{
	ChAutoPtr<WrdEmbeddedTrueTypeFontTable> pClone(ChNEW WrdEmbeddedTrueTypeFontTable);
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Пример #11
0
CursorEventPtr MouseEvent::cloneAs(Type EventType) const
{
    MouseEventPtr pClone(new MouseEvent(*this));
    pClone->m_Type = EventType;
    return pClone;
}
Пример #12
0
ChEXPORT WrdSmartTags* WrdSmartTags::clone() const
{
	ChAutoPtr<WrdSmartTags> pClone(ChNEW WrdSmartTags());
	return pClone.giveUpOwnership();
}
Пример #13
0
ChEXPORT WrdStringTable* WrdStringTable::clone() const
{
	ChAutoPtr<WrdStringTable> pClone(ChNEW WrdStringTable());
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Пример #14
0
ChEXPORT WrdKeyboardShortcut* WrdKeyboardShortcut::clone() const
{
	ChAutoPtr<WrdKeyboardShortcut> pClone(ChNEW WrdKeyboardShortcut());
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Пример #15
0
ChEXPORT WrdBookmark* WrdBookmark::clone() const
{
	ChAutoPtr<WrdBookmark> pClone(ChNEW WrdBookmark());
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Пример #16
0
CursorEventPtr TangibleEvent::cloneAs(Type eventType) const
{
    TangibleEventPtr pClone(new TangibleEvent(*this));
    pClone->m_Type = eventType;
    return pClone;
}
ChEXPORT WrdMenuCustomizationOperation* WrdMenuCustomizationOperation::clone() const
{
	ChAutoPtr<WrdMenuCustomizationOperation> pClone(ChNEW WrdMenuCustomizationOperation());
	*pClone = *this;
	return pClone.giveUpOwnership();
}
Пример #18
0
    intrusive_ptr<Document> DocumentSourceUnwind::getCurrent() {
        if (!pNoUnwindDocument.get()) {
            intrusive_ptr<Document> pInDocument(pSource->getCurrent());

            /* create the result document */
            pNoUnwindDocument = pInDocument;
            fieldIndex.clear();

            /*
              First we'll look to see if the path is there.  If it isn't,
              we'll pass this document through.  If it is, we record the
              indexes of the fields down the field path so that we can
              quickly replace them as we clone the documents along the
              field path.

              We have to clone all the documents along the field path so
              that we don't share the end value across documents that have
              come out of this pipeline operator.
             */
            intrusive_ptr<Document> pCurrent(pInDocument);
            const size_t pathLength = unwindPath.getPathLength();
            for(size_t i = 0; i < pathLength; ++i) {
                size_t idx = pCurrent->getFieldIndex(
                    unwindPath.getFieldName(i));
                if (idx == pCurrent->getFieldCount() ) {
                    /* this document doesn't contain the target field */
                    resetArray();
                    return pInDocument;
                    break;
                }

                fieldIndex.push_back(idx);
                Document::FieldPair fp(pCurrent->getField(idx));
                intrusive_ptr<const Value> pPathValue(fp.second);
                if (i < pathLength - 1) {
                    if (pPathValue->getType() != Object) {
                        /* can't walk down the field path */
                        resetArray();
                        uassert(15977, str::stream() << unwindName <<
                                ":  cannot traverse field path past scalar value for \"" <<
                                fp.first << "\"", false);
                        break;
                    }

                    /* move down the object tree */
                    pCurrent = pPathValue->getDocument();
                }
                else /* (i == pathLength - 1) */ {
                    if (pPathValue->getType() != Array) {
                        /* last item on path must be an array to unwind */
                        resetArray();
                        uassert(15978, str::stream() << unwindName <<
                                ":  value at end of field path must be an array",
                                false);
                        break;
                    }

                    /* keep track of the array we're unwinding */
                    pUnwindArray = pPathValue;
                    if (pUnwindArray->getArrayLength() == 0) {
                        /*
                          The $unwind of an empty array is a NULL value.  If we
                          encounter this, use the non-unwind path, but replace
                          pOutField with a null.

                          Make sure unwind value is clear so the array is
                          removed.
                        */
                        pUnwindValue.reset();
                        intrusive_ptr<Document> pClone(clonePath());
                        resetArray();
                        return pClone;
                    }

                    /* get the iterator we'll use to unwind the array */
                    pUnwinder = pUnwindArray->getArray();
                    assert(pUnwinder->more()); // we just checked above...
                    pUnwindValue = pUnwinder->next();
                }
            }
        }

        /*
          If we're unwinding a field, create an alternate document.  In the
          alternate (clone), replace the unwound array field with the element
          at the appropriate index.
         */
        if (pUnwindArray.get()) {
            /* clone the document with an array we're unwinding */
            intrusive_ptr<Document> pUnwindDocument(clonePath());

            return pUnwindDocument;
        }

        return pNoUnwindDocument;
    }