* We need to cast to BFile instead of BNode, as BNode is not a subclass of
BPositionIO. This fixes ticket #4299. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32568 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2004-2005, Axel Dörfler, [email protected]. All rights reserved.
|
* Copyright 2004-2009, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@
|
|||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
#include <TypeConstants.h>
|
#include <TypeConstants.h>
|
||||||
#include <ByteOrder.h>
|
#include <ByteOrder.h>
|
||||||
#include <Node.h>
|
#include <File.h>
|
||||||
#include <Font.h>
|
#include <Font.h>
|
||||||
|
|
||||||
#include <AutoDeleter.h>
|
#include <AutoDeleter.h>
|
||||||
@@ -588,7 +588,7 @@ convert_to_stxt(RTF::Header &header, BDataIO &target)
|
|||||||
|
|
||||||
status = swap_data(B_UINT32_TYPE, &styleHeader, sizeof(styleHeader),
|
status = swap_data(B_UINT32_TYPE, &styleHeader, sizeof(styleHeader),
|
||||||
B_SWAP_HOST_TO_BENDIAN);
|
B_SWAP_HOST_TO_BENDIAN);
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
written = target.Write(&styleHeader, sizeof(styleHeader));
|
written = target.Write(&styleHeader, sizeof(styleHeader));
|
||||||
@@ -617,12 +617,12 @@ convert_to_plain_text(RTF::Header &header, BPositionIO &target)
|
|||||||
void *flattenedRuns = NULL;
|
void *flattenedRuns = NULL;
|
||||||
int32 flattenedSize = 0;
|
int32 flattenedSize = 0;
|
||||||
|
|
||||||
// ToDo: this is not really nice, we should adopt the BPositionIO class
|
// TODO: this is not really nice, we should adopt the BPositionIO class
|
||||||
// from Dano/Zeta which has meta data support
|
// from Dano/Zeta which has meta data support
|
||||||
BNode *node = dynamic_cast<BNode *>(&target);
|
BFile *file = dynamic_cast<BFile *>(&target);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
TextOutput output(header, &target, node != NULL);
|
TextOutput output(header, &target, file != NULL);
|
||||||
|
|
||||||
output.Work();
|
output.Work();
|
||||||
flattenedRuns = output.FlattenedRunArray(flattenedSize);
|
flattenedRuns = output.FlattenedRunArray(flattenedSize);
|
||||||
@@ -630,16 +630,17 @@ convert_to_plain_text(RTF::Header &header, BPositionIO &target)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node == NULL) {
|
if (file == NULL) {
|
||||||
// we can't write the styles
|
// we can't write the styles
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
// put out styles
|
// put out styles
|
||||||
|
|
||||||
ssize_t written = node->WriteAttr("styles", B_RAW_TYPE, 0, flattenedRuns, flattenedSize);
|
ssize_t written = file->WriteAttr("styles", B_RAW_TYPE, 0, flattenedRuns,
|
||||||
|
flattenedSize);
|
||||||
if (written >= B_OK && written != flattenedSize)
|
if (written >= B_OK && written != flattenedSize)
|
||||||
node->RemoveAttr("styles");
|
file->RemoveAttr("styles");
|
||||||
|
|
||||||
free(flattenedRuns);
|
free(flattenedRuns);
|
||||||
return B_OK;
|
return B_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user